package com.ieslab.powergrid.demosvr.controller;

import com.ieslab.powergrid.demosvr.entity.ErrorStatus;
import com.ieslab.powergrid.demosvr.entity.Result;
import com.ieslab.powergrid.demosvr.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/rest")
public class RestTestController {
    @Autowired
    PersonService personService;

    @RequestMapping("/index")
    public Result getData(String id){
        Map map = new HashMap<>();
        map.put("id", id);
        return Result.ok(personService.getPersons(map));
    }

    @RequestMapping("/index2")
    public Result getData2(){
        return Result.error(ErrorStatus.INTERNAL_SERVER_ERROR);
    }

    @RequestMapping("/index3")
    public Result getData3(){
        int a = 1/0;
        return Result.ok();
    }
}
